﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameEngine;
using Ignitron.EEngine.Maths;

namespace Board3D.Animation
{
    internal class RotationBoardAnimation: Animation
    {
        protected double _startXRotation;
        protected double _finishXRotation;
        protected double _startYRotation;
        protected double _finishYRotation;

        public RotationBoardAnimation(double startXRotation, double finishXRotation, double startYRotation, double finishYRotation,
                        TimeSpan animationLength)
            : base(Position.Empty, animationLength)
        {
            _startXRotation = startXRotation;
            _finishXRotation = finishXRotation;
            _startYRotation = startYRotation;
            _finishYRotation = finishYRotation;
        }

        public override void GetRotationParameters(out float rotationX, out float rotationY)
        {
            rotationX = 0;
            rotationY = 0;

            float delta = 0;
            if (base.GetAnimationDelta(out delta) == false)
            {
                rotationX = (float)_finishXRotation;
                rotationY = (float)_finishYRotation;
                return;
            }

            double lengthX = _finishXRotation - _startXRotation;
            double lengthY = _finishYRotation - _startYRotation;

            rotationX = (float)(_startXRotation + lengthX * delta);
            rotationY = (float)(_startYRotation + lengthY * delta);
        }
    }
}
